package org.hugh.space.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class RemoveServlet extends BaseSpringServlet {
	
	
	private static final long serialVersionUID = 6098745782027999297L;
	private static final Log log = LogFactory.getLog(FileDownloadServlet.class);

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

        log.debug("get file " + request.getPathInfo());
		
		getDao().getFileDao().remove(getId(request.getPathInfo()));
//		request.getRequestDispatcher("/fileList").forward(request, response);
		response.sendRedirect("/fileList");
	}
	
	private String getId(String pathInfo){
		String[] chain = pathInfo.split("/");
		return chain[chain.length-1];
	}
	
}